package encaps.entities;

import encaps.utils.StringUtil;

public enum OrderType {

    ASCENT("asc"), DESCENT("desc"), NONE(null);

    private OrderType(String value) {
        this.value = value;
    }

    @Override
    public String toString() {
        return value;
    }

    public static OrderType getOrderType(String type) {
        if ("asc".equalsIgnoreCase(type)) {
            return ASCENT;
        }
        if ("desc".equalsIgnoreCase(type)) {
            return DESCENT;
        }
        return NONE;
    }

    public static OrderType getOppositeOrder(String order) {
        if (StringUtil.isEmpty(order)) {
            return ASCENT;
        } else if (order.equalsIgnoreCase("asc")) {
            return DESCENT;
        } else {
            return ASCENT;
        }
    }
    private String value;
}
